# Maintainer: Christian Rebischke <chris.rebischke@archlinux.org>

pkgname=syft
pkgver=0.94.0
pkgrel=1
pkgdesc="CLI tool and library for generating a Software Bill of Materials from container images and filesystems"
arch=('loong64' 'x86_64')
url="https://github.com/anchore/syft"
license=('Apache')
makedepends=('go' 'git')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/anchore/${pkgname}/archive/v${pkgver}.tar.gz")
sha512sums=('171b23271f03e1e824dcac41a563f7947d004797a21e762eea883ea680e0de65a532e03e4b245a4021288fec60142da8c1c16d6520eadece65728728b9d15f91')
b2sums=('892c7bf90a1d15fd926207acd1a28e8bd907ae5869be763e48ccd8d3279975c2ec84d9ec5842e3799460a823b5aa611a028982d8d40d90248c1cfad25415c672')

build(){
  cd "${pkgname}-${pkgver}"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -ldflags=-linkmode=external -trimpath -modcacherw"
  mkdir build
  go mod tidy
  go build -o build/ ./...
}

# disabled, needs docker
# check() {
#  cd "${pkgname}-${pkgver}"
#  go test -v ./...
# }

package() {
  cd "${pkgname}-${pkgver}"
  install -Dm755 build/syft "${pkgdir}/usr/bin/${pkgname}"
}

